package day12;

/**
 * @author oldliu
 * @since 1.0
 */
public class Depositer extends Thread {
    private final Accout ac;

    public Depositer(String name, Accout ac) {
        super(name);
        this.ac = ac;
    }

    @Override
    public void run() {
        while (true) {
            try {
                sleep(1500);
                ac.deposit(2000);
                synchronized (ac) {
                    ac.notifyAll();
                }

                System.out.println(this.getName() + "存钱2000，当前余额是" + ac.getMoney() + "元！");
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
